package org.pleasantnightmare.noraxidium.info;

import org.apache.log4j.Logger;
import org.lwjgl.util.Rectangle;
import org.newdawn.slick.Color;
import org.newdawn.slick.Font;
import org.newdawn.slick.Graphics;
import org.newdawn.slick.Image;
import org.newdawn.slick.SlickException;
import org.pleasantnightmare.noraxidium.NoraxidiumGameContainer;
import org.pleasantnightmare.noraxidium.collision.CollisionRenderer;
import org.pleasantnightmare.noraxidium.collision.RectBound;
import org.pleasantnightmare.noraxidium.math.GameVector2f;
import org.pleasantnightmare.noraxidium.model.GameObject;
import org.pleasantnightmare.noraxidium.model.LevelMap;
import org.pleasantnightmare.noraxidium.model.Rendered;
import org.pleasantnightmare.noraxidium.support.DisplaySupport;

/**
 * Renders information text
 *
 * @author Calvin
 * @version 1.0
 * @since Jul 13, 2010 
 */
public class InfoRenderer implements Rendered 
{
	private static final Logger LOGGER = Logger.getLogger(CollisionRenderer.class);
	private LevelMap m_levelMap;
	private GameObject player;
	Image infoFrame;
	final String infoFramePath="sprites/InfoFrame.png";
	private NoraxidiumGameContainer gameContainer;
	private NoraxidiumGameContainer supportContainer;
	
	/**
	 * @return the player
	 */
	public GameObject getPlayer() {
		return player;
	}

	/**
	 * @param player the player to set
	 */
	public void setPlayer(GameObject player) {
		this.player = player;
	}

	public InfoRenderer(NoraxidiumGameContainer ngc)
	{
		gameContainer = ngc;
		try {
			infoFrame = new Image(infoFramePath);
		} catch (SlickException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	
	@Override public void render(Graphics g) 
	{
		//test info
	    String strInfo=new String();
	        
	    GameVector2f pos = player.getPosition();
		    
	    strInfo = String.format("Info-> Pozicija:  X = %f; Y = %f", pos.x, pos.y);
	    
	    //todo: gdje je igrac na karti, tj postoji li na poziciji na kojoj je igrac neki info tekst
	   /* ovo ne radi, treba pronaci tile na koordinati playera 
	    int tileID=0;
	    	    
	    tileID = m_levelMap.getMap().getTileId((int)pos.x, (int)pos.y, 0);
	    
	    strInfo = m_levelMap.getMap().getTileProperty(tileID, "info", "No info");
	    */
	    g.drawImage(infoFrame, 0, gameContainer.getHeight() - infoFrame.getHeight());
	    
		if (strInfo!=null)
		{
		    g.setColor(Color.black);
		    g.drawString(strInfo, 20, gameContainer.getHeight() - infoFrame.getHeight()+20);
		}
	}


	public void setCurrentMap(LevelMap currentMap) {
		m_levelMap=currentMap;
		
	}
}
